<?php

namespace App\Http\Controllers\Common;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ZanController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function make(Request $request){
//        return $request;
        $model=hd_model();

        if($zan=$model->isZan(auth()->user())){
            $zan->delete();
        }else{
            $model->zans()->create(['user_id'=>auth()->id()]);
        }
        if ($request->ajax()){
            return ['code'=>0,'count'=>hd_model()->zan_num];
        }

        return back();
    }

}
